//
//  ModifyHeadImgBtn.m
//  JiaoX
//
//  Created by yinqy on 15/1/28.
//  Copyright (c) 2015年 北京娇羞科技有限公司. All rights reserved.
//

#import "ModifyHeadImgBtn.h"
#define BTN_HEIGHT [DimensUtils getScaleX:69]
#define HEADIMG_HEIGHT [DimensUtils getScaleX:39]

@implementation ModifyHeadImgBtn

- (instancetype)initWithHeadImgUrl:(NSString *)url
{
    self = [super init];
    if (self) {
        self.size = CGSizeMake(JXScreenW, BTN_HEIGHT);
        
        UILabel *headLabel = [[UILabel alloc]init];
        [headLabel setTextColor:JXColor(102, 102, 102)];
        [headLabel setFont:[UIFont systemFontOfSize:NAME_FONT]];
        NSString *headLabelStr = @"头像";
        [headLabel setText:headLabelStr];
        CGSize headLabelSize = [headLabelStr sizeWithFont:headLabel.font];
        [headLabel setFrame:CGRectMake(JXPublicInset, (BTN_HEIGHT-headLabelSize.height)/2, headLabelSize.width, headLabelSize.width)];
        [self addSubview:headLabel];
        _headLabel =headLabel;
        
        UIImageView *arrowImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"self_item_arrow"]];
        
        arrowImage.x = JXScreenW-JXPublicInset-arrowImage.width;
        arrowImage.y = (BTN_HEIGHT-arrowImage.height)/2;
        [self addSubview:arrowImage];
        _arrowImage = arrowImage;
        
        UIImageView *headImage = [[UIImageView alloc]init];
        [headImage sd_setImageWithURL:[NSURL URLWithString:url]];
        [headImage setFrame:CGRectMake(CGRectGetMinX(_arrowImage.frame)-5-HEADIMG_HEIGHT, (BTN_HEIGHT-HEADIMG_HEIGHT)/2, HEADIMG_HEIGHT, HEADIMG_HEIGHT)];
        [headImage.layer setCornerRadius:HEADIMG_HEIGHT/2];
        headImage.layer.masksToBounds = YES;
        [self addSubview:headImage];
        _headImage = headImage;
    }
    return self;
}

@end
